//导入全局样式表
import './assets/css/globe.css'
import {createApp} from 'vue'
import App from './App.vue'
import router from './router'
import ElementPlus from 'element-plus';
import 'element-plus/theme-chalk/index.css';
import axios from 'axios'
import cookies from 'vue-cookies'
// axios.defaults.baseURL = 'api';
axios.defaults.withCredentials = true;

// 请求拦截器
axios.interceptors.request.use(
    config => {
        let token = sessionStorage.getItem('accessToken');
        if (token !== null && token !== '') {
            config.headers = {
                token: token,
            }
            // alert('获取token：'+token)
        }
        return config;
    },
    error => {
        console.log("请求出错，错误信息如下：");
        console.log(error);
        Promise.reject(error);
    }
);


const app = createApp(App)
app.use(router)
app.use(ElementPlus)
app.mount('#app')
//配置axios全局使用
app.config.globalProperties.$http = axios
app.config.globalProperties.$cookies = cookies;
